package org.jctc.els.modules.biz.controller.experts;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.jctc.els.modules.biz.entity.user.User;
import org.jctc.els.modules.biz.service.user.IUserService;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.annotation.MultipartConfig;

import static org.springblade.core.cache.constant.CacheConstant.USER_CACHE;

@RestController
@RequestMapping("/experts")
@NonDS
@ApiIgnore
@AllArgsConstructor
@MultipartConfig
public class ExpertsController {

    private IUserService userService;

    @GetMapping("/page")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "account", value = "账号名", paramType = "query", dataType = "string")
    })
    public R<IPage<User>> page(@ApiIgnore Query query,
                               @RequestParam(value = "account",required = false) String account) {
        System.out.println("query"+query);
        IPage<User> pages = userService.selectExpertsPage(Condition.getPage(query),account,"");
        return R.data(pages);
    }



    @ApiOperation(value = "新增用户表")
    @PostMapping("/save")
    public R save(@RequestBody User user) {
        user.setRoleId("1540591713518571521");
        user.setBaseRole(4l);//专家角色
        user.setStatus(1);//默认启用
        return R.status(userService.insert(user));
    }

}
